const TODOLIST = 'TODOLIST'

export let todoStorage = {
    fetch() {
        return JSON.parse(localStorage.getItem(TODOLIST)) || []
    },
    save(todos) {
        localStorage.setItem(TODOLIST, JSON.stringify(todos))
    }
}

export let filters = {
    all(todos) {
        return todos
    },
    active(todos) {
        return todos.filter(todo => !todo.completed)
    },
    completed(todos) {
        return todos.filter(todo => todo.completed)
    },
}